import { defineStore } from 'pinia'
export const useUserStore = defineStore(
  'user',
  () => {
    const userInfo = ref({})
    // 登录时调用 getUserInfo()方法 获取用户信息
    const getUserInfo = async () => {
      const res = await getUserInfoAPI()
      userInfo.value = res.data
    }
    // 退出登录时 clearUserInfo()方法清除用户信息
    const clearUserInfo = async () => {
      userInfo.value = {}
    }

    return { userInfo, getUserInfo, clearUserInfo }
  },
  {
    persist: true
  }
)
